package 线程.day2.demo8;

import java.util.concurrent.CountDownLatch;

public class Test {
    public static void main(String[] args) {
        CountDownLatch cd=new CountDownLatch(6);
        String[]arr={"韩","赵","魏","楚","燕","齐","秦"};
        for(String msg:arr){
            new Thread(new Runnable() {
                @Override
                public void run() {
                    if(msg.equals("秦")){
                        try {
                            cd.await();
                        } catch (InterruptedException e) {}
                        System.out.println("-------------项楚亡秦---------------");

                    }else {
                        System.out.println(Thread.currentThread().getName()+"被秦灭掉！");
                        cd.countDown();
                    }
                }
            },msg).start();
        }
    }
}
